package org.kabeja.dxf.helpers;

/**
 * @author shutao
 * @since 2022/4/24 17:46
 */
public class HatchLineFamily {
    private double rotationAngle;
    private double baseX;
    private double baseY;
    private double offsetX;
    private double offsetY;
    private double length = 0.0D;
    private double[] pattern = new double[0];

    public HatchLineFamily() {
    }

    public double getBaseX() {
        return this.baseX;
    }

    public void setBaseX(double var1) {
        this.baseX = var1;
    }

    public double getBaseY() {
        return this.baseY;
    }

    public void setBaseY(double var1) {
        this.baseY = var1;
    }

    public double getOffsetX() {
        return this.offsetX;
    }

    public void setOffsetX(double var1) {
        this.offsetX = var1;
    }

    public double getOffsetY() {
        return this.offsetY;
    }

    public void setOffsetY(double var1) {
        this.offsetY = var1;
    }

    public double[] getPattern() {
        return this.pattern;
    }

    public void setPattern(double[] var1) {
        if (var1 != null) {
            this.pattern = var1;
        }

    }

    public double getRotationAngle() {
        return this.rotationAngle;
    }

    public void setRotationAngle(double var1) {
        this.rotationAngle = var1;
    }

    public double getLength() {
        if (this.length <= 0.0D) {
            for (double v : this.pattern) {
                this.length += Math.abs(v);
            }
        }

        return this.length;
    }

    public double getPatternWidth() {
        return this.getLength() * Math.cos(this.rotationAngle);
    }

    public double getPatternHeight() {
        return this.getLength() * Math.sin(this.rotationAngle);
    }

    public Point getBasePoint() {
        return this.transform(this.baseX, this.baseY);
    }

    public Point getOffsetPoint() {
        return this.transform(this.offsetX, this.offsetY);
    }

    protected Point transform(double var1, double var3) {
        Point var5 = new Point();
        var5.setX(Math.cos(this.rotationAngle) * var1 + Math.sin(this.rotationAngle) * var3);
        var5.setY(Math.cos(this.rotationAngle) * var3 - Math.sin(this.rotationAngle) * var1);
        return var5;
    }

    public Point getMinimalBasePoint() {
        Point var1 = new Point();
        Point var2 = this.getBasePoint();
        Point var3 = this.getOffsetPoint();
        var1.setX(var2.getX() % var3.getX());
        var1.setY(var2.getY() % var3.getY());
        return var1;
    }
}
